package edu.guigu.appquickstart.recyclerview;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;

import edu.guigu.appquickstart.R;
import edu.guigu.appquickstart.base.BaseActivity;
import edu.guigu.appquickstart.recyclerview.ex1.UserListActivity;
import edu.guigu.appquickstart.recyclerview.ex2.PersonListActivity;

public class RecyclerviewActivity extends BaseActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview);
        // Actionbar
        setSupportActionBar(findViewById(R.id.toolbar));
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        // 监听处理
        findViewById(R.id.btn_userbean).setOnClickListener(this);
        findViewById(R.id.btn_personbean).setOnClickListener(this);
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        if(v.getId() == R.id.btn_userbean){
            intent.setClass(this, UserListActivity.class);
            startActivity(intent);
        }
        if(v.getId() == R.id.btn_personbean){
            intent.setClass(this, PersonListActivity.class);
            startActivity(intent);
        }
    }
}